bean 'viewFactoryBase', parent:'abstractViewFactory',
custom: [
	defaultActionMapRenderingOptions:'LABEL_ICON'
]

controller 'JspressotTester.name',
icon:'icon.png',
context:'JspressotTester',
language:'en',
workspaces:[
	'JspressoTester'
]

workspace('JspressoTester') {
	filterModule('Node.module', component:'Node')
	filterModule('Segment.module', component:'Segment')
	filterModule('Voyage.module', component:'Voyage', moduleView:'Voyage.module.view', detailView:'Voyage.detail.view')
	filterModule('TestEntity.module', component:'TestEntity', moduleView:'TestEntity.module.view')
	filterModule('TestScope.module', component:'TestScope')
	filterModule('BackActionTest.module', component:'BackActionTest', moduleView:'BackActionTest.module.view')
  filterModule('Repeater.module', component:'Voyage', moduleView:'Repeater.module.view')
}


/**
 * Entity type choice base actions
 */
action('chooseEntityActionBase', class:'org.jspresso.framework.application.frontend.action.entity.ChooseEntityActionBase',
icon:'classpath:org/jspresso/framework/application/images/find-48x48.png',
custom:[ecludedComponents:[
		'org.jspresso.framework.security.UsernamePasswordHandler',
		'org.jspresso.model.Traceable',
		'org.jspresso.model.EntityDescriptor',
		'org.jspresso.model.TestScope',
		'org.jspresso.model.TestEntity',
		'org.jspresso.model.ActionTestIo',
		'org.jspresso.model.ActionTestOutput',
		'org.jspresso.model.EntityDescriptorPicker',
		'org.jspresso.framework.application.backend.AbstractBackendController',
		'org.jspresso.model.ActionTestInput',
		'org.jspresso.framework.application.backend.async.AsyncActionExecutor',
		'org.jspresso.model.BackActionTest',
		'org.jspresso.framework.model.entity.IEntity']]) {
	next(parent:'editComponentAction', custom:[cancelAction_ref:'cancelDialogFrontAction', okAction_ref:'okChooseEntityAction', viewDescriptor_ref:'EntityDescriptorPicker.view'])
}
		
action('okChooseEntityAction', parent:'okDialogFrontAction', class:'org.jspresso.framework.application.frontend.action.entity.OkChooseEntityAction')
		


/**
 *	Deletes the TestEntity instance already existing on the ref field if this is a generated TestEntity (ie: that has been created or cloned only for this ActionTestIo).
 *	Also acts as a collection adder in situation where this is called for a List typed ActionTestIo
 */
action('deleteTestEntityIfRequiredToViewConnectorSetAction', parent:'viewConnectorSetAction', class:'org.jspresso.framework.application.frontend.action.std.DeleteTestEntityIfRequiredToViewConnectorSetAction') {
	next(ref:'saveModuleObjectBackAction')
}

/**
 * Deletes a TestEntity instance from a collection if this is a generated TestEntity (ie: that has been created or cloned only for this ActionTestIo).
 * Removes the entry from collection otherwise
 */
action('removeTestEntityCollectionFrontAction', parent:'removeEntityCollectionFromMasterFrontAction', custom:[yesAction_ref:'removeTestEntityCollectionOkFrontAction'], name:'removeTestEntityCollectionFrontAction')
action('removeTestEntityCollectionOkFrontAction', parent:'okDialogFrontAction') {
	next(class:'org.jspresso.framework.application.backend.action.RemoveTestEntityCollectionFrontAction', custom:[removeCollectionFromMasterAction_ref:'removeCollectionFromMasterAction', deleteCollectionFromMasterAction_ref:'removeCollectionFromMasterBackAction'])
}
action('removeCollectionFromMasterAction', class:'org.jspresso.framework.application.backend.action.RemoveCollectionFromMasterAction')

/**
 * Entity type choice to lov actions
 */
action('chooseEntityForLovAction', parent:'chooseEntityActionBase', name:'chooseEntityForLovAction') {
	next(parent:'editComponentAction', custom:[cancelAction_ref:'cancelDialogFrontAction', okAction_ref:'okChooseEntityForLovAction', viewDescriptor_ref:'EntityDescriptorPicker.view'])
}

action('okChooseEntityForLovAction', parent:'okChooseEntityAction') {
	next(class:'org.jspresso.framework.application.frontend.action.entity.lov.ChoosenEntityLovAction', parent:'lovAction', custom:[okAction_ref:'okChoosenEntityLovAction'])
}

action('okChoosenEntityLovAction', parent:'lovOkFrontAction', class:'org.jspresso.framework.application.frontend.action.entity.lov.OkChoosenEntityLovAction', next:null, custom:[viewConnectorSetAction_ref:'deleteTestEntityIfRequiredToViewConnectorSetAction'])


/**
 * Entity type choice to creation actions
 */
action('chooseEntityForCreationAction', parent:'chooseEntityActionBase', name:'chooseEntityForCreationAction') {
	next(parent:'editComponentAction', custom:[cancelAction_ref:'cancelDialogFrontAction', okAction_ref:'okChooseEntityForCreationAction', viewDescriptor_ref:'EntityDescriptorPicker.view'])
}

action('okChooseEntityForCreationAction', parent:'okChooseEntityAction') {
	next(class:'org.jspresso.framework.application.frontend.action.entity.creation.ChoosenEntityCreationAction', parent:'editComponentAction', custom:[cancelAction_ref:'cancelDialogFrontAction', okAction_ref:'okChoosenEntityCreationAction', viewDescriptor_ref:'allEntities.cardView'])
}

action('okChoosenEntityCreationAction', parent:'okDialogFrontAction', class:'org.jspresso.framework.application.frontend.action.entity.creation.OkChoosenEntityCreationAction', next:'deleteTestEntityIfRequiredToViewConnectorSetAction')


/**
 * Entity choice within input parameters to a cloned instance
 */
action('chooseEntityToCloneAction', parent:'editComponentAction', class:'org.jspresso.framework.application.frontend.action.entity.clone.ChooseEntityToCloneAction', custom:[viewDescriptor_ref:'TestEntityPicker.view', cancelAction_ref:'cancelDialogFrontAction', okAction_ref:'chooseEntityToCloneOkAction'], name:'chooseEntityToCloneAction')

action('chooseEntityToCloneOkAction', parent:'okDialogFrontAction') {
	wrapped(class:'org.jspresso.framework.application.frontend.action.entity.clone.ChooseEntityToCloneOkAction', custom:[cloneFactory_ref:'smarterEntityCloneFactory'])
	next(ref:'choosenEntityToCloneEditAction')
}

action('choosenEntityToCloneEditAction', parent:'editComponentAction', custom:[okAction_ref:'okChoosenEntityCreationAction', cancelAction_ref:'cancelDialogFrontAction', viewDescriptor_ref:'allEntities.cardView'])

/**
 * TestEntity edition
 */
action('editTestEntityAction', parent:'editComponentAction', class:'org.jspresso.framework.application.frontend.action.std.EditTestEntityAction',custom:[okAction_ref:'okChoosenEntityEditionAction', cancelAction_ref:'cancelDialogFrontAction', viewDescriptor_ref:'allEntities.cardView'], name:'editTestEntityAction')

action('okChoosenEntityEditionAction', parent:'okChoosenEntityCreationAction') {
	 next(parent:'viewConnectorSetAction', class:'org.jspresso.framework.application.frontend.action.std.SetConnectorValueAndFireChangeEventAction') {
		 next(ref:'saveModuleObjectBackAction')
	 }
}



/**
 * Enhanced clone factory
 */
bean('smarterEntityCloneFactory', class:'org.jspresso.framework.model.entity.SmarterEntityCloneFactory')


/**
 * Switch a model for any referenced view
 */
action('switchModelForView', class:'org.jspresso.framework.application.frontend.action.SwitchModelForView', icon:'classpath:org/jspresso/framework/application/images/view-48x48.png', name:'switchModelForView')


/**
 * Load and store entities to the default TestScope
 */
action('loadEntityFromTestEntity', name:'jspressoTest.loadEntityFromTestEntity', icon:'classpath:org/jspresso/framework/application/images/2downarrow-48x48.png', parent:'abstractFrontendAction', class:'org.jspresso.framework.application.frontend.action.LoadEntityFromTestEntity')
action('storeEntityAsTestEntity', name:'jspressoTest.storeEntityAsTestEntity', icon:'classpath:org/jspresso/framework/application/images/2uparrow-48x48.png', parent:'abstractFrontendAction', class:'org.jspresso.framework.application.frontend.action.StoreEntityAsTestEntity')


/**
 * Displays entity represented by the selected TestEntity
 **/
action('displayEntityFromTestEntity', parent:'loadEntityFromTestEntity') {
	next(parent:'editComponentAction', custom:[cancelAction_ref:'cancelDialogFrontAction', okAction_ref:'okDialogFrontAction', viewDescriptor_ref:'allEntities.cardView'])
}


/**
 * Data-source switching
 */
action('swithTestSituationFrontAction', parent:'abstractFrontendAction', class:'org.jspresso.framework.application.frontend.action.SwithTestSituationFrontAction')
action('switchToTestEnvironnement', parent:'swithTestSituationFrontAction', custom:[toTestSituation:true], icon:'classpath:org/jspresso/framework/application/images/up-48x48.png')
action('switchToNormalEnvironnement', parent:'swithTestSituationFrontAction', custom:[toTestSituation:false], icon:'classpath:org/jspresso/framework/application/images/down-48x48.png')


/**
 * Test runners
 */
action('runSelectedBackActionTestFrontAction', parent:'abstractFrontendAction', class:'org.jspresso.framework.application.frontend.action.RunSelectedBackActionTestFrontAction', custom:[toTestEnvironnementAction_ref:'switchToTestEnvironnement', toNormalEnvironnementAction_ref:'switchToNormalEnvironnement'], icon:'classpath:org/jspresso/framework/application/images/wizard-48x48.png') {
	wrapped(ref:'saveModuleObjectBackAction')
	next(ref:'checkAllModulesDirtyStateFrontAction')
}

/**
 *  View repeater 
 **/
bean('viewRepeater', class:'org.jspresso.framework.application.view.descriptor.BasicRepeaterViewDescriptor', custom:[basicGridViewDescriptor_ref:'BasicGrid.view'])
bean('formViewRepeater', parent:'viewRepeater', custom:[itemViewDescriptor_ref:'Segment.detail.view'])

action('addCollectionPropertyAsChildModuleFrontAction', parent:'addAsChildModuleFrontAction', class:'org.jspresso.framework.application.frontend.action.AddCollectionPropertyAsChildModuleFrontAction') {
//  wrapped(class:'org.jspresso.framework.application.backend.action.module.AddCollectionPropertyAsBeanSubModuleAction')
//  next(ref:'moduleSelectionFrontAction')
}


evenGrid('BasicGrid.view', drivingDimension:'ROW', drivingCellCount:1)